<?php 


class index_index extends MX_Controller {
	
	public function index(){
		//reset session
		$this->load->library('session');
		$this->session->sess_destroy();
		
		
		$localisation= $this->load->module('localisation/index');
		$location=$localisation->getlocation();
		$code_postal=$location->Postalcode;
		$location->getlocationCodePostal($code_postal);
		$name_region=$location->Nom_Region; 
		$code_postal=substr ($code_postal,0,2);

		$setting =$this->load->Module('setting/admin');
		$setting_admin=$setting->get_admin();
		$description=$setting_admin['description'];
		$keywords=$setting_admin['keywords'];
		$title=$setting_admin['name'];
		$total_annonce=$this->model()->total_annonces()->total;
		
		$category= $this->load->module('category/index');
		
		$this->load->driver('cache');
		if ( ! $menu_footer_category = $this->cache->file->get('menu_footer_category'))
		{
			$menu_footer_category=$category->check_list_cats_footer(0, 0,  0, null,$this->config->config['base_url']);
			// Save into the cache for 5 minutes
			$this->cache->file->save('menu_footer_category', $menu_footer_category, 300);
		}
		//$menu_footer_category=$category->check_list_cats_footer(0, 0,  0, null,$this->config->config['base_url']);
		 
		$data=array(
				'title'=>$title,
				'description'=>$description,
				'keywords'=>$keywords, 
				'menu_footer_category'=>$menu_footer_category,  
				'total_annonce'=>$total_annonce,
				'name_region'=>$name_region,
				'code_postal_user'=>$code_postal
		); 

		$setting=$this->load->Module('setting/data');
		$data=$setting->data($data);
		
		$this->view(
				array('header',
						'index',
						'footer'),
				$data); // Display the page
    }

}
